package com.itheima.homework2;

import java.util.Scanner;

public class homework2 {
    /*
     已知用户名和密码，请用程序实现模拟用户登录。总共给三次机会，是否登录成功，给出相应的提示。
     */
    public static void main(String[] args) {
        String name = "admin";
        String mima = "123";
        Scanner sc = new Scanner(System.in);
        for (int i = 1; i <=3; i++) {
            System.out.println("请输入用户名:");
            String username = sc.nextLine();
            System.out.println("请输入密码:");
            String password = sc.nextLine();
            if(username.equals(name)&&password.equals(mima)){
                System.out.println("登录成功");
            }else{
                if(i==3){
                    System.out.println("您今天的次数已达上限!");
                }else{
                    System.out.println("用户名或密码有误,您还有"+(3-i)+"次机会");
                }

            }
        }
    }
}
